package com.xzmzhp.dao.cosmetic;

import com.xzmzhp.pojo.cosmetic.CosmeticType;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author 宋雪
 * @Date: 2020/11/15 19:21
 * @Description: 化妆品类别数据操作类
 */

@Repository
public interface CosmeticTypeMapper {
    /**
     * 添加化妆品种类
     *
     * @param name 化妆品类型名称
     * @return Integer
     */
    @Insert("insert into cosmetic_type(cosmetic_type_name) values(#{name})")
    Integer addCosmeticType(@Param("name") String name);

    /**
     * 根据id删除化妆品种类
     *
     * @param id 化妆品类型id
     * @return Integer
     */
    @Delete("delete from cosmetic_type where cosmetic_type_id=#{id}")
    Integer deleteCosmeticType(@Param("id") Integer id);

    /**
     * 根据id修改化妆品种类
     *
     * @param cosmeticType 化妆品种类
     * @return Integer
     */
    @Update("update cosmetic_type set cosmetic_type_name=#{cosmeticTypeName} where cosmetic_type_id=#{cosmeticTypeId}")
    Integer updateCosmeticType(CosmeticType cosmeticType);

    /**
     * 查询所有化妆品种类
     *
     * @return 相关化妆品类型信息
     */
    @Select("select cosmetic_type_id,cosmetic_type_name from cosmetic_type")
    List<CosmeticType> selectCosmeticTypesAll();

    /**
     * 根据id查询化妆品种类
     *
     * @param id 化妆品类型id
     * @return 相关化妆品类型信息
     */
    @Select("select cosmetic_type_id,cosmetic_type_name from cosmetic_type where cosmetic_type_id=#{id}")
    CosmeticType selectCosmeticTypeById(@Param("id") Integer id);

    /**
     * 根据化妆品类型名称查询化妆品类型信息
     *
     * @param cosmeticTypeName 化妆品类型名称
     * @return 相关化妆品类型信息
     */
    @Select("select cosmetic_type_id,cosmetic_type_name from cosmetic_type where cosmetic_type_name=#{cosmeticTypeName}")
    List<CosmeticType> selectCosmeticTypeByName(@Param("cosmeticTypeName") String cosmeticTypeName);
}
